home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-05-29 | 2.0 KB | 65 lines | [TEXT/CWIE] |
- // =================================================================================
- // CMemoryIndicator.cp ©1997 BB's Team inc. All rights reserved
- // =================================================================================
- #include "CMemoryIndicator.h"
- #include "PLConstants.h"
- #include <LString.h>
-
- // ---------------------------------------------------------------------------------
- // • Stream ctor
- // ---------------------------------------------------------------------------------
- CMemoryIndicator::CMemoryIndicator (LStream *inStream)
- : CGreyCaption (inStream)
- , mFree (0)
- , mIntro ("\p")
- {}
-
-
- // ---------------------------------------------------------------------------------
- // • CreateMemoryIndicatorStream [static]
- // ---------------------------------------------------------------------------------
- CMemoryIndicator *
- CMemoryIndicator::CreateMemoryIndicatorStream (LStream *inStream)
- {
- return new CMemoryIndicator (inStream);
- }
-
-
- // ---------------------------------------------------------------------------------
- // • FinishCreateSelf
- // ---------------------------------------------------------------------------------
- void CMemoryIndicator::FinishCreateSelf (void)
- {
- // get the introductory text from PPob
- GetDescriptor (mIntro);
-
- // Force initialization of the caption
- SpendTime ();
-
- StartIdling();
- }
-
-
- // ---------------------------------------------------------------------------------
- // • SpendTime
- // ---------------------------------------------------------------------------------
- void CMemoryIndicator::SpendTime (void)
- {
- EventRecord lostEvent;
- SpendTime (lostEvent);
- }
-
-
- // ---------------------------------------------------------------------------------
- // • SpendTime
- // ---------------------------------------------------------------------------------
- void CMemoryIndicator::SpendTime (const EventRecord &)
- {
- Int32 theFreeMem = ::FreeMem() / 1024;
- if (theFreeMem != mFree) {
- mFree = theFreeMem;
- LStr255 theUnit (rSTR, kKb);
- SetDescriptor (mIntro + LStr255(mFree) + theUnit);
- }
- }
-